// ml:run = $bin < input
#include <iostream>
#include <string>
#include <map>

std::map<char, int> m{{'C', 12}, {'H', 1}, {'O', 16}};

int main()
{
    std::ios_base::sync_with_stdio(false);
    int T; std::cin >> T;
    while (T--) {
        std::string s;
        std::cin >> s;
        int ans = 0;
        for (auto ch : s)
            ans += m[ch];
        std::cout << ans << "\n";
    }
}

